package com.umanji.building.domain;

import java.util.Collection;
import java.util.Date;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.OrderBy;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;
import javax.persistence.UniqueConstraint;

import org.springframework.web.multipart.commons.CommonsMultipartFile;

import com.umanji.enterprise.domain.Enterprises;
import com.umanji.generic.entity.UUIDEntity;

@Entity
@Table(name="umanji_building", uniqueConstraints = {@UniqueConstraint(columnNames={"BUILDING_NO"})})
public class Buildings extends UUIDEntity<Buildings> {

	@OneToMany(cascade=CascadeType.ALL, mappedBy="building")
	@OrderBy("regDate")
	private Set<BuildingInfos> buildingInfos;		// 이지미

	@OneToMany(cascade=CascadeType.ALL, mappedBy="building")
	@OrderBy("regDate")
	private Set<Enterprises> enterprises;		// 이지미

	@Column(name="BUILDING_NO", length=25)
	private String buildingNo;

	@Column(name="TITLE", length=150)
	private String title;

	@Column(name="CONTENT", length=250)
	private String content;

	@Column(name="IMAGE_FILE", length=100)
	private String imgFile;

	@Transient
	private CommonsMultipartFile fileData;

	@Temporal(TemporalType.DATE)
	private Date regDate;

	public Date getRegDate() {
		return regDate;
	}

	public void setRegDate(Date regDate) {
		this.regDate = regDate;
	}

	public String getBuildingNo() {
		return buildingNo;
	}
	public void setBuildingNo(String buildingNo) {
		this.buildingNo = buildingNo;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public String getImgFile() {
		return imgFile;
	}

	public void setImgFile(String imgFile) {
		this.imgFile = imgFile;
	}

	public Set<Enterprises> getEnterprises() {
		return enterprises;
	}

	public void setEnterprises(Set<Enterprises> enterprises) {
		this.enterprises = enterprises;
	}

	public Set<BuildingInfos> getBuildingInfos() {
		return buildingInfos;
	}

	public void setBuildingInfos(Set<BuildingInfos> buildingInfos) {
		this.buildingInfos = buildingInfos;
	}

	public void setFileData(CommonsMultipartFile fileData) {
		this.fileData = fileData;
	}

	public CommonsMultipartFile getFileData() {
		return fileData;
	}

}
